package analysis;

import java.util.List;

import object.Utente;
import mysql.DBCache;
import mysql.Tweet2db;

public class CreateSecondCluster {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	DBCache db = new DBCache();
	Tweet2db tb = new Tweet2db();
	
	List<Utente> list = db.getUtentiByItem("android");//LEVARE LA LIMIT
	for (Utente u : list){
		System.out.println(u.getNome());
		int apple =0;
		int windows =0;
		int android =0;
		List<String> l = db.getTweetAmico(u.getId());
		for (String s:l){
			if (s.toLowerCase().contains("apple") | s.toLowerCase().contains("ios")|s.toLowerCase().contains("ipad")|s.toLowerCase().contains("iphone"))
					apple++;
			else if (s.toLowerCase().contains("windows")|s.toLowerCase().contains("wp")|s.toLowerCase().contains("microsoft")|s.toLowerCase().contains("xp")){
					windows++;
					}
			else if (s.toLowerCase().contains("android")|s.toLowerCase().contains("ics")|s.toLowerCase().contains("google")){
				android++;
				}
		
		}
		if ((apple>windows) & (apple>android)){
				tb.nuovocluster("apple", u.getNome(),u.getId(),"no");
				}
			else if (windows>apple & windows > android){
				tb.nuovocluster("windows", u.getNome(),u.getId(),"no");
				}
			else if (android>windows & android > apple){
				tb.nuovocluster("android", u.getNome(),u.getId(),"no");
			}
			else {
				tb.nuovocluster("android", u.getNome(),u.getId(),"no");
			}
		}
		}
	}
	

